package com.middlegroup.payadmin.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.middlegroup.payadmin.pojo.po.Bank;
import com.middlegroup.payadmin.pojo.po.Channels;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 通道表 Mapper 接口
 * </p>
 *
 * @author pc123
 * @since 2019-01-04
 */
public interface ChannelsMapper extends BaseMapper<Channels> {

    /**
     * 查询通道列表
     * @param name
     * @param serviceType
     * @return
     */
    List<Channels> listChannels(@Param("name") String name,@Param("serviceType") Long serviceType);

    /**获取渠道下配置的银行信息
     * @param code
     * @return 返回渠道下银行列表
     */
    @Select("SELECT t1.bank_name,t1.bank_code, CASE WHEN (SELECT 1 FROM t_channel_bank_router WHERE channel_code=#{code} AND bank_code=t1.bank_code ) THEN 1 ELSE 0 END AS flag FROM t_bank t1 where t1.enabled=1")
    List<Bank> getChannelBanks(@Param("code") String code);

}
